/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ruipengkj.bean.TExeStageTmpl;
import com.ruipengkj.commons.base.query.BaseQuery;
import com.ruipengkj.commons.base.query.PageModel;
import com.ruipengkj.dao.TExeStageTmplDao;
import com.ruipengkj.service.TExeStageTmplService;
/**
 * 说明：
 * 优惠券service层接口实现
 * @Author：李智深
 * @Date：2012-03-16
 */
@Service
public class TExeStageTmplServiceImpl implements TExeStageTmplService{
	@Resource
	private TExeStageTmplDao TExeStageTmplDao;//DAO层
	
	
	//查询所有
	@Override
	public List<TExeStageTmpl> findService(TExeStageTmpl entity) throws Exception {
		String hql = "select o from TExeStageTmpl o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return TExeStageTmplDao.findDao(hql, whereHQL.toString(), param, orderby);
	}

	//根据ID翻页查询
	@Override
	public PageModel<TExeStageTmpl> getScrollService(int firstResult,
			int maxResult, TExeStageTmpl entity) throws Exception {
		String hql = "select o from TExeStageTmpl o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(entity.getName()!=null&&!entity.getName().equals("")){
				whereHQL.append("name").append(BaseQuery.LIKE).append("?").append(BaseQuery.AND);
				param.add("%"+entity.getName()+"%");
			}
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return TExeStageTmplDao.getScrollDao(hql, whereHQL.toString(), param, firstResult, maxResult, orderby);
	}

	//修改
	@Override
	public void modifyService(TExeStageTmpl entity) throws Exception {
		TExeStageTmplDao.modifyDao(entity);
		
	}
	//添加
	@Override
	public void saveService(TExeStageTmpl entity) throws Exception {
		TExeStageTmplDao.saveDao(entity);
	}
	//根据ID删除
	@Override
	public void deleteService(String id) throws Exception {
		TExeStageTmplDao.deleteDao(id);
		
	}
	//根据ID查询
	@Override
	public TExeStageTmpl getByIdService(String id) throws Exception {
		return TExeStageTmplDao.getByIdDao(id);
	}
	//添加或修改
	@Override
	public void saveOrUpdateService(TExeStageTmpl entity) throws Exception {
		TExeStageTmplDao.saveOrUpdateDao(entity);
	}
	//添加返回ID
	@Override
	public Serializable saveRetService(TExeStageTmpl entity) throws Exception {
		return TExeStageTmplDao.saveRetDao(entity);
	}
	public TExeStageTmplDao getTExeStageTmplDao() {
		return TExeStageTmplDao;
	}

	public void setTExeStageTmplDao(TExeStageTmplDao TExeStageTmplDao) {
		this.TExeStageTmplDao = TExeStageTmplDao;
	}
}
